package com.shop2cn.iapi.shenqisettlement.testcase;

import java.math.BigDecimal;
import java.util.*;

import com.ymttest.business.service.shenqi.*;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.shenqisettlement.parameter.OnHpSettledReq;
import com.shop2cn.iapi.shenqisettlement.parameter.SaveProxyFissionConfigReq;
import com.shop2cn.iapi.shenqisettlement.parameter.bean.AgentProductBean;
import com.shop2cn.iapi.shenqisettlement.service.OnHpSettledCall;
import com.shop2cn.iapi.shenqisettlement.verify.ShenqiSettlementBuildVerifyService;
import com.shop2cn.iapi.sqoptrade.parameter.enums.CancelOrderTypeEnum;
import com.shop2cn.iapi.sqoptrade.resp.Order;
import com.shop2cn.iapi.sqoptrade.resp.TradingServiceResp;
import com.ymatou.iapi.synctrade.service.TradingSyncService;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.SQPayGateWayCallService;
import com.ymttest.business.service.shenqi.bean.ShenqiUserSet;
import com.ymttest.common.order.userquery.util.Utils;
import com.ymttest.database.sharding.db.sharding.model.OrderPo;
import com.ymttest.database.sharding.db.sharding.model.PaymentDetailPo;
import com.ymttest.database.sharding.db.sharding.model.PaymentPo;
import com.ymttest.database.sharding.db.sqlwapper.OrderShardingWapper;
import com.ymttest.database.sqlwapper.DGUserWapper;
import com.ymttest.database.sqlwapper.shenqisettlement.DependentMerchantFeeConfigWrapper;

public class Ts_ShenqiSettlement {

	private static OnHpSettledReq hpSettledReq = null;
	private static OnHpSettledCall hpSettledCall = new OnHpSettledCall();

	private static OrderShardingWapper wapper = new OrderShardingWapper();
	private static DependentMerchantFeeConfigWrapper dependentMerchantFeeConfigWrapper = new DependentMerchantFeeConfigWrapper();

	private static ShenqiSettlementBuildVerifyService shenqiSettlementBuildVerifyService = new ShenqiSettlementBuildVerifyService();

	// 盛付通手续费率
	private static String shengPayRate = "0.001";

	private static long autotest_goodsOwnerId = ShenqiUserSet.autotest_goodsOwnerId;

	private static long japanGoodsOwnerId = ShenqiUserSet.japanGoodsOwnerId;
	private static long UKGoodsOwnerId = ShenqiUserSet.UKGoodsOwnerId;
	private static long shengPayGoodsOwnerId = ShenqiUserSet.shengPayGoodsOwnerId;
	private static long whitelistGoodsOwnerId = ShenqiUserSet.whitelistGoodsOwnerId;
	private static long shengPayWhitelistGoodsOwnerId = ShenqiUserSet.shengPayWhitelistGoodsOwnerId;
	private static long dualPayModeGoodsOwnerId = ShenqiUserSet.dualPayModeGoodsOwnerId;
	private static long multiCurrencyGoodsOwnerId = ShenqiUserSet.multiCurrencyGoodsOwnerId;
	private static long proxyFissionGoodsOwnerId = ShenqiUserSet.proxyFissionGoodsOwnerId;
	private static long yabandGoodsOwnerId = ShenqiUserSet.yabandGoodsOwnerId;
	private static long chainStoreGoodsOwnerId = ShenqiUserSet.chainStoreGoodsOwnerId;
	private static long fundNotCollectGoodsOwnerId = ShenqiUserSet.fundNotCollectGoodsOwnerId;
	private static long macaoCDFGoodsOwnerId = ShenqiUserSet.macaoCDFGoodsOwnerId;
	private static long platformSupplierGoodsOwnerId = ShenqiUserSet.platformSupplierGoodsOwnerId;
	private static long platformIndependentGoodsOwnerId = ShenqiUserSet.platformIndependentGoodsOwnerId;
	private static long CHNGoodsOwnerId = ShenqiUserSet.CHNGoodsOwnerId;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("代购神器结算");

		/**
		 * 将未结算的结算单置为废弃,防止结算的时间过长
		 */
		// orderSettlementWrapper.updateStatus();
	}

	@Before
	public void caseUp() {
		String accountid1;
		try {
			accountid1 = AccountCallServiceV2.getAccountId(20238699);
			AccountCallServiceV2.resetAccount(accountid1, new BigDecimal(
					9000000), new BigDecimal(0));

			hpSettledReq = new OnHpSettledReq();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult("api/onHpSettled");

		// new MchFeeConfigWrapper().deleteAutotestData();
		wapper.activeDeadCommunicationsLink(wapper);
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private void onHpSettled(long paymentId, PaymentPo payment,
			String shengPayRate, int count) throws Exception {

		if (count < 6) {

			hpSettledReq.setTradingId(paymentId);
			hpSettledReq.setOrderAmount(payment.getRealPaidAmount());
			hpSettledReq.setSettleCurrency(payment.getSettleCurrency());
			hpSettledReq
					.setSettleAmount(payment.getRealForeignAmount() != null ? payment
							.getRealForeignAmount() : payment
							.getForeignAmount());

			if (shengPayRate != null) {

				hpSettledReq.setSettleFee(payment.getRealPaidAmount().multiply(
						new BigDecimal(shengPayRate)));
			}

			hpSettledCall.setData(hpSettledReq);
			hpSettledCall.callService();

			if (!"ok".equalsIgnoreCase(hpSettledCall.getReturnData())) {

				Thread.sleep(3000 + count * 3000);
				count++;
				this.onHpSettled(paymentId, payment, shengPayRate, count);
			}
		} else {

			throw new Exception();
		}
	}

	/**
	 * 
	 * @param paymentId
	 *            hp结算
	 *            结算单结算
	 *            代收货款时，货头结算
	 * @throws Exception
	 */
	public void verify(long paymentId, HashMap<String, Boolean> map)
			throws Exception {

		List<PaymentDetailPo> paymentDetails = wapper
				.selectPaymentDetailByPaymentId(paymentId);

		// 校验order_settlement和order_settlement_detail
		shenqiSettlementBuildVerifyService.verifySettlement(paymentDetails,
				Utils.falseIfNull(map.get("hpSettled")),
				Utils.falseIfNull(map.get("settled")),
				Utils.falseIfNull(map.get("isForeignExchangeBid")),
				Utils.falseIfNull(map.get("isRefunded")),
				Utils.falseIfNull(map.get("isRefundedFailed")),
				Utils.falseIfNull(map.get("isCollectingForOthersSettled")),
				hpSettledReq);
	}

	/**
	 * 
	 * @param paymentId
	 * @param hpSettled
	 *            hp结算
	 * @param settled
	 *            结算单结算
	 * @param isForeignExchangeBid
	 * @param isRefunded
	 * @param isRefundedFailed
	 * @param isCollectingForOthersSettled
	 *            代收货款时，货头结算
	 * @throws Exception
	 */
	public void verify(long paymentId, boolean hpSettled, boolean settled,
			Boolean isForeignExchangeBid, Boolean isRefunded,
			Boolean isRefundedFailed, Boolean isCollectingForOthersSettled)
			throws Exception {

		Logger.comment(String.valueOf(isForeignExchangeBid));

		List<PaymentDetailPo> paymentDetails = wapper
				.selectPaymentDetailByPaymentId(paymentId);

		// 校验order_settlement和order_settlement_detail
		shenqiSettlementBuildVerifyService.verifySettlement(paymentDetails,
				hpSettled, settled, isForeignExchangeBid, isRefunded,
				isRefundedFailed, isCollectingForOthersSettled, hpSettledReq);
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_001() {
		Logger.start(true, "代购神器，代理链（货头-店主），未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false,
							false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_002() {
		Logger.start(true, "代购神器，代理链（货头-店主-代理），未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			// PlaceOrderReq placeOrderReq = SqTradingCallService
			// .buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
			// productBean, productBean.getSellerId(), true);
			//
			// TradingServiceResp placeOrderResp =
			// TradingCallService.callPlaceOrderService(placeOrderReq);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_003() {
		Logger.start(true, "代购神器，代理链（货头-店主），未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// long autotest_goodsOwnerId = 500146002;
			//
			// AgentProductBean productBean = new AgentProductBean();
			//
			// productBean.setSellerId(500221984);
			// productBean.setSellerLoginId("500221984");
			// productBean.setProductId("p2732856");
			// productBean.setCatalogList(Arrays.asList("c4880067"));
			// productBean.setCurrency("CNY");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);
			//
			// TradingServiceResp placeOrderResp = SqTradingCallService
			// .placeOrder(productBean, BigDecimal.ZERO,
			// autotest_goodsOwnerId, "CNY");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_004() {
		Logger.start(true, "代购神器，代理链（货头-店主-代理），未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_010() {
		Logger.start(true, "代购神器，直销商下单，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			// AgentProductBean productBean = SqTradingCallService
			// .createProxychain(500776876, 0, false);

			// AgentProductBean productBean = new AgentProductBean();
			//
			// productBean.setSellerId(500067469);
			// productBean.setSellerLoginId("autotest500067469");
			// productBean.setProductId("p1823626");
			// productBean.setCatalogList(Lists.newArrayList("c3047047"));
			//
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder1(productBean, productBean.getSellerId());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(productBean.getSellerId(),
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_011() {
		Logger.start(true, "代购神器两个子订单，未调价，未结算，退第一个订单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(BigDecimal.ZERO, productBean, 1);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 取消订单
			RefundService.createFullRefundSuccess(orderId,
					autotest_goodsOwnerId, paymentId, userId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_012() {
		Logger.start(true, "代购神器两个子订单，向上调价，已经结算，退第一个订单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(BigDecimal.TEN, productBean, 1);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			for (Order order : placeOrderResp.getOrderList()) {

				SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
						order.getOrderId());
				TradingSyncService.getSyncResult(order.getOrderId());
			}

			// 代购神器结算
			ShenqiSettlementService.doSettlement();
			Thread.sleep(3000);

			// 取消订单
			RefundService.createFullRefundSuccess(orderId,
					autotest_goodsOwnerId, paymentId, userId);
			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_013() {
		Logger.start(true, "代购神器，代理链（货头-渠道商-店主-代理），未调价，已接单，多币种，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 日本的渠道商
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createJPProxychain(500058147, 2, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 500058147);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(500058147, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_016() {
		Logger.start(true, "代购神器，代理链（货头-店主），币种为CNY，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, currency);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_017() {
		Logger.start(true, "代购神器，代理链（货头-店主），币种为USD，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false,
							true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, currency);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_020() {
		Logger.start(true, "代购神器，直销商下单，外币订单，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false,
							true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder1(productBean, productBean.getSellerId(),
							currency);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(productBean.getSellerId(),
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_021() {
		Logger.start(true, "代购神器，代理链（货头-渠道商-渠道商-店主-代理），未调价，已接单，币种为英镑，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 英国的渠道商
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createUKProxychain((int) UKGoodsOwnerId, 3, true, true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO, UKGoodsOwnerId,
							currency);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(UKGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_022() {
		Logger.start(true, "代购神器，代理链（货头-渠道商-店主-代理），未调价，已接单，币种为日元，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 日本的渠道商
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createJPProxychain((int) japanGoodsOwnerId, 2, true, true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							japanGoodsOwnerId, currency);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), placeOrderResp
							.getOrderList().get(0).getSellerId().toString());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(japanGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_023() {
		Logger.start(true, "代购神器，代理链（货头-渠道商-渠道商-店主-代理），未调价，已接单，币种为韩元，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 韩国的渠道商
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createKRProxychain(500072235, 2, true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO, 500072235,
							currency);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(500072235, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_024() {
		Logger.start(true, "代购神器，代理链（货头-渠道商-渠道商-店主-代理），未调价，已接单，特殊币种为新西兰币，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 新西兰的渠道商
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createNZLProxychain(500173397, 2, true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO, 500173397,
							currency);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(500173397, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_026() {
		Logger.start(true, "代购神器继承代理下单，利润为0，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Integer mchId = DGSQBaseService.createIndependenceMch("USA");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createInheritedProxychain((int) mchId, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeInheritedOrder(productBean, (int) mchId, 4321, true);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long userId = placeOrderResp.getUserId();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), placeOrderResp
							.getPayableAmount().subtract(BigDecimal.ZERO)
							.toString(), (int) userId,
					BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder((int) mchId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_027() {
		Logger.start(true, "代购神器代理商交易下单,多个商品，一个订单，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithMultiProsInOneOrder(productBean);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long userId = placeOrderResp.getUserId();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), placeOrderResp
							.getPayableAmount().subtract(BigDecimal.ZERO)
							.toString(), (int) userId,
					BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder((int) autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			Thread.sleep(5000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_028() {
		Logger.start(true,
				"代购神器，代理链（货头-渠道商-渠道商-代理），未调价，已接单，货头特殊币种为新西兰币，代理商币种为美元，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 新西兰的货头
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createNZLProxychain(500173397, 2, false);
			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"USA");

			// 使用人民币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO, 500173397, "CNY");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(500173397, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			Thread.sleep(5000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_029() {
		Logger.start(true,
				"代购神器，代理链（货头-渠道商-渠道商-代理），未调价，已接单，货头美元币种，渠道商特殊币种韩元，代理商欧元结算，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"KOR");

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"NLD");

			// 使用人民币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, "CNY");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_030() {
		Logger.start(true,
				"代购神器，代理链（货头-渠道商-渠道商-渠道商-代理），英国货头，日本渠道商，澳大利亚渠道商，香港代理，未调价，外币支付，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 英国的货头，外币支付
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createUKProxychain((int) UKGoodsOwnerId, 1, false, true);

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"AUS");

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"HKG");

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"JPN");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO, UKGoodsOwnerId,
							"GBP");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), placeOrderResp
							.getOrderList().get(0).getSellerId().toString());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), "GBP");

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(UKGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_031() {
		Logger.start(true, "代购神器，软件服务商-货头-店主，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 创建代理链
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) UKGoodsOwnerId, 1, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO, UKGoodsOwnerId,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_032() {
		Logger.start(true, "代购神器，软件服务商-货头，直销订单，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 创建代理链
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) UKGoodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO, UKGoodsOwnerId,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_034() {
		Logger.start(true, "代购神器，软件服务商-货头，货头币种为日元，直销订单，未调价，已接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createGoodsOwnerProduct(japanGoodsOwnerId, "USD", false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder1(productBean, productBean.getSellerId());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(japanGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_035() {
		Logger.start(true, "代购神器，软件服务商-货头-店主-代理，服务商为HKG，未调价，已接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 英国的货头，外币支付
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createUKProxychain((int) UKGoodsOwnerId, 1, false, true);

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"AUS");

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"HKG");

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"JPN");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO, UKGoodsOwnerId,
							"GBP");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), "GBP");

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(UKGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_037() {
		Logger.start(true, "代购神器，货头-店主-代理，独立商户，未调价，已接单，hp结算，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			int userId_channel = DGSQBaseService.createIndependenceMch("USA");
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain(userId_channel, 1, false,
							false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, userId_channel);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(userId_channel, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_038() {
		Logger.start(true, "代购神器，货头-代理，独立商户（日币），未调价，已接单，hp结算，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			int userId_channel = DGSQBaseService.createIndependenceMch("JPN");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createInheritedProxychain(userId_channel, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, userId_channel);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(userId_channel, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_039() {
		Logger.start(true, "代购神器，货头-代理，独立商户（日币），未调价，已接单，hp结算，已结算，平台费大于结算费用");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// AgentProductBean productBean = SqTradingCallService
			// .createProxychain((int) autotest_goodsOwnerId, 1, false);

			int userId_channel = DGSQBaseService.createIndependenceMch("JPN");
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createInheritedProxychain(userId_channel, false);

			// 设置独立商户的费率
			dependentMerchantFeeConfigWrapper.insert(userId_channel,
					new BigDecimal("5.00"), new BigDecimal("10.00"));

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, userId_channel);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(userId_channel, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	// 盛付通需要分账后才能结算，分账需要修改数据
	public void Tc_ShenqiSettlement_041() {
		Logger.start(true, "代购神器，代理链（货头-店主），使用盛付通支付，未调价，已接单，hp结算， 已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createShengPayProxychain((int) shengPayGoodsOwnerId, 0);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithPayChannelType(productBean,
							shengPayGoodsOwnerId, 2);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			hpSettledCall.setData(hpSettledReq);
			hpSettledCall.callService();

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(shengPayGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 发货
			SqTradingCallService.delivery(shengPayGoodsOwnerId, orderId, null, null);
			TradingSyncService.getSyncResult(orderId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_043() {
		Logger.start(true,
				"代购神器，代理链（货头-渠道商-渠道商-代理），未调价，已接单，货头为白名单用户，货头美元币种，渠道商特殊币种韩元， 渠道商特殊币种为港元"
						+ "代理商欧元结算，非外币支付，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							false);

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"KOR");

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"HKG");

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"NLD");

			// 使用人民币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							whitelistGoodsOwnerId, "CNY");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_044() {
		Logger.start(true, "代购神器，代理链（货头-渠道商-渠道商-代理），未调价，已接单，货头为白名单用户，货头美元币种，"
				+ "第一级渠道商分摊货头的费率，渠道商特殊币种韩元，代理商欧元结算，外币支付，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							true);

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"KOR");

			// 设置下级费率百分比
			GodmchManageCallService.setAgentRate(whitelistGoodsOwnerId, 399144,
					new BigDecimal("5"));

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"NLD");

			// 外币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							whitelistGoodsOwnerId, "USD");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), "USD");

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_045() {
		Logger.start(true,
				"代购神器，代理链（货头-渠道商-渠道商-渠道商-代理），美国货头，白名单用户，日本渠道商，中国代理，未调价，外币支付，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头，外币支付
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							true);

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"JPN");

			// 设置下级费率百分比
			GodmchManageCallService.setAgentRate(whitelistGoodsOwnerId, 399144,
					new BigDecimal("5"));

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"CHN");

			// 外币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							whitelistGoodsOwnerId, "USD");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), placeOrderResp
							.getOrderList().get(0).getSellerId().toString());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), "USD");

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_046() {
		Logger.start(true,
				"代购神器，代理链（货头-渠道商-渠道商-渠道商-代理），美国货头，白名单用户，日本渠道商，香港代理，未调价，非外币支付，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// // 美元货头，外币支付
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							false);

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"JPN");

			// // 设置下级费率百分比
			GodmchManageCallService.setAgentRate(whitelistGoodsOwnerId, 399144,
					new BigDecimal("5"));

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"HKG");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							whitelistGoodsOwnerId, "CNY");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());


			// // 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());


			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_047() {
		Logger.start(true, "代购神器，直销订单，未调价，已接单，货头为白名单用户，货头美元币种，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							false);

			// 使用人民币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							whitelistGoodsOwnerId, "CNY");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_048() {
		Logger.start(true, "代购神器，代理链（货头-渠道商-渠道商-渠道商-代理），盛付通白名单用户，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createShengPayWhiteMerchantProxychain(
							(int) shengPayWhitelistGoodsOwnerId, 2);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithPayChannelType(productBean,
							shengPayWhitelistGoodsOwnerId, 2);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(
					shengPayWhitelistGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_049() {
		Logger.start(true,
				"代购神器，代理链（货头-渠道商-渠道商-渠道商-代理），美国货头，白名单用户，日本渠道商，中国代理，未调价，非外币支付，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头，外币支付
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							false);

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"JPN");

			// 设置下级费率百分比
			GodmchManageCallService.setAgentRate(whitelistGoodsOwnerId, 399144,
					new BigDecimal("5"));

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"CHN");

			// 人民币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							whitelistGoodsOwnerId, "CNY");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), placeOrderResp
							.getOrderList().get(0).getSellerId().toString());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			hpSettledCall.setData(hpSettledReq);
			hpSettledCall.callService();

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_050() {
		Logger.start(true, "代购神器，代理链（货头-代理），美国货头，白名单用户，中国代理，未调价，非外币支付，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头，外币支付
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							false);

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"CHN");

			// 设置下级费率百分比
			GodmchManageCallService.setAgentRate(whitelistGoodsOwnerId, 399144,
					new BigDecimal("20"));

			// 人民币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							whitelistGoodsOwnerId, "CNY");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), placeOrderResp
							.getOrderList().get(0).getSellerId().toString());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_051() {
		Logger.start(true, "代购神器，代理链（货头-代理），美国货头，白名单用户，中国代理，未调价，外币支付，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头，外币支付
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							true);

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"CHN");

			// 设置下级费率百分比
			GodmchManageCallService.setAgentRate(whitelistGoodsOwnerId, 399144,
					new BigDecimal("20"));

			// 外币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							whitelistGoodsOwnerId, "USD");

			// PlaceOrderReq placeOrderReq = SqTradingCallService
			// .buildDGSQStandPlaceOrderReq(0, BigDecimal.ZERO, 20238699,
			// productBean, whitelistGoodsOwnerId, true);
			//
			// placeOrderReq.setCurrency(productBean.getCurrency());
			//
			// TradingServiceResp placeOrderResp =
			// TradingCallService.callPlaceOrderService(placeOrderReq);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), placeOrderResp
							.getOrderList().get(0).getSellerId().toString());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), "USD");

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_052() {
		Logger.start(true,
				"代购神器，代理链（货头-代理），美国货头，白名单用户，中国代理，未调价，非外币支付宝支付，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头，外币支付
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							false);

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"CHN");

			// 设置下级费率百分比
			GodmchManageCallService.setAgentRate(whitelistGoodsOwnerId, 399144,
					new BigDecimal("20"));

			// 人民币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							whitelistGoodsOwnerId, "CNY");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6006");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6006);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_053() {
		Logger.start(true, "代购神器，代理链（货头-代理），美国货头，中国代理，未调价，外币支付宝支付，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头，外币支付
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							true);

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"CHN");

			// 外币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							whitelistGoodsOwnerId, "USD");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6006");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), "USD",
					6006);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_054() {
		Logger.start(true, "代购神器，货头-代理，独立商户（日币），支付宝支付，未调价，已接单，hp结算，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// AgentProductBean productBean = SqTradingCallService
			// .createProxychain((int) autotest_goodsOwnerId, 1, false);

			int userId_channel = DGSQBaseService.createIndependenceMch("JPN");
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createInheritedProxychain(userId_channel, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, userId_channel);

			// TradingServiceResp placeOrderResp = SqTradingCallService
			// .placeOrder(productBean, BigDecimal.ZERO, userId_channel, "JPY");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6006");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6006);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(userId_channel, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_056() {
		Logger.start(true, "代购神器，软件服务商-货头，货头币种为日元，直销订单，支付宝支付，未调价，已接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 创建软件服务商
			int userId_channel = DGSQBaseService.createProvider("USA");

			// 绑定软件服务商和货头
			DGSQBaseService.createServiceRelation(userId_channel,
					japanGoodsOwnerId, 3);

			// 设置软件服务商和货头的费率
			ShenqiSettlementService.setUserPlatformFeeSetting(
					(long) userId_channel, 2);
			ShenqiSettlementService.setUserPlatformFeeSetting(
					japanGoodsOwnerId, 8);

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createGoodsOwnerProduct(japanGoodsOwnerId, "USD", false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder1(productBean, productBean.getSellerId());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6006");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6006);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(japanGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_057() {
		Logger.start(true,
				"代购神器，代理链（货头-渠道商-渠道商-渠道商-代理），英国货头，日本渠道商，澳大利亚渠道商，香港代理，未调价，外币支付宝支付，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 英国的货头，外币支付
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createUKProxychain((int) UKGoodsOwnerId, 1, false, true);

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"AUS");

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"HKG");

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"JPN");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO, UKGoodsOwnerId,
							"GBP");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6006");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), "GBP",
					6006);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(UKGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_058() {
		Logger.start(true, "代购神器直销，未调价，支付宝支付，已接单，特殊币种为新西兰币，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 韩国的渠道商
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createNZLProxychain(500173397, 0, false);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							productBean.getSellerId(), currency);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6006");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6006);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(productBean.getSellerId(),
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_059() {
		Logger.start(true, "代购神器，一个支付单多个订单，盛付通白名单用户，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createShengPayWhiteMerchantProxychain(
							(int) shengPayWhitelistGoodsOwnerId, 2);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(BigDecimal.ZERO, productBean, null,
							BigDecimal.ZERO, shengPayWhitelistGoodsOwnerId, 2);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(
					shengPayWhitelistGoodsOwnerId, orderId);

			SqTradingCallService.sellerAcceptOrder(
					shengPayWhitelistGoodsOwnerId, placeOrderResp
							.getOrderList().get(1).getOrderId());

			TradingSyncService.getSyncResult(orderId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_062() {
		Logger.start(true,
				"代购神器外币标价商品，直销订单并支付，CustomSettlementCurrencyType为1，盛付通双通道用户，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) dualPayModeGoodsOwnerId, 0, false,
							true);

			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 1, 2, dualPayModeGoodsOwnerId,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRateForTe = DGSQBaseService
					.getCurrencyConfig(currency).getExchangeRmbRateForTe();

			// 支付网关支付回调交易
			SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(BigDecimal.ZERO)
									.multiply(exchangeRmbRateForTe)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(dualPayModeGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Thread.sleep(5000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_063() {
		Logger.start(true,
				"代购神器商品，直销订单并支付，CustomSettlementCurrencyType为1，盛付通双通道用户，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) dualPayModeGoodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 1, 2, dualPayModeGoodsOwnerId,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(dualPayModeGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_064() {
		Logger.start(true,
				"代购神器商品，直销订单并支付，CustomSettlementCurrencyType为2，盛付通双通道用户，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) dualPayModeGoodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 2, 2, dualPayModeGoodsOwnerId,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(dualPayModeGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_065() {
		Logger.start(true,
				"代购神器外币标价商品，直销订单并支付，CustomSettlementCurrencyType为2,双通道用户，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) dualPayModeGoodsOwnerId, 0, false,
							true);
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 2, 1, dualPayModeGoodsOwnerId,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(dualPayModeGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			Thread.sleep(5000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_066() {
		Logger.start(true,
				"代购神器商品，直销订单并支付，CustomSettlementCurrencyType为2,双通道用户，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// AgentProductBean productBean = SqTradingCallService
			// .createProxychain((int)dualPayModeGoodsOwnerId, 0, false);

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) 500181307, 0, false);
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 2, 500181307L,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(500181307L, orderId);

			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			Thread.sleep(5000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_067() {
		Logger.start(true, "代购神器，多货头，多币种下单，结算币种为日币，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithSuppliers(autotest_goodsOwnerId, 1,
							500058147L, 5);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			SqTradingCallService.sellerAcceptOrder(500058147L, placeOrderResp
					.getOrderList().get(1).getOrderId());
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_068() {
		Logger.start(true, "代购神器，多货头，多币种下单，结算币种为美元，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithSuppliers(autotest_goodsOwnerId, 5,
							500058147L, 1);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			SqTradingCallService.sellerAcceptOrder(500058147L, placeOrderResp
					.getOrderList().get(1).getOrderId());
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_069() {
		Logger.start(true, "代购神器，多货头，多币种下单，盛付通通道，结算币种为日币，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithSuppliers(autotest_goodsOwnerId, 1,
							500058147L, 5, 2);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			SqTradingCallService.sellerAcceptOrder(500058147L, placeOrderResp
					.getOrderList().get(1).getOrderId());
			TradingSyncService.getSyncResult(orderId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	// 供应商导入商品出错
	public void Tc_ShenqiSettlement_070() {
		Logger.start(true, "代购神器，多供应商，多币种下单，盛付通，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Integer mchId = DGSQBaseService.createIndependenceMch("USA");

			// 创建第一个供货商商品
			AgentProductBean supplierProductBean_1 = DGSQBuildProxyChainCallService
					.createSupplierProduct(mchId, "USA", "CNY", false);

			AgentProductBean agentProductBean_1 = DGSQBuildProxyChainCallService
					.importAgentProduct(mchId, supplierProductBean_1);

			agentProductBean_1 = DGSQBuildProxyChainCallService
					.createIndependenceChannel(mchId, mchId,
							agentProductBean_1.getProductId(), "CHN");
			agentProductBean_1.setGoodsOwnerId(supplierProductBean_1
					.getGoodsOwnerId());

			// 创建第二个供货商商品
			AgentProductBean supplierProductBean_2 = DGSQBuildProxyChainCallService
					.createSupplierProduct(mchId, "JPN", "CNY", false);

			AgentProductBean agentProductBean_2 = DGSQBuildProxyChainCallService
					.importAgentProduct(mchId, supplierProductBean_2);

			agentProductBean_2 = DGSQBuildProxyChainCallService
					.importAgentProduct(agentProductBean_1.getSellerId(),
							agentProductBean_2);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithTwoSuppliers(agentProductBean_1, 1,
							agentProductBean_2, 3, null, 2);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(
					supplierProductBean_1.getSellerId(), orderId);
			TradingSyncService.getSyncResult(orderId);

			SqTradingCallService.sellerAcceptOrder(
					supplierProductBean_2.getSellerId(), placeOrderResp
							.getOrderList().get(1).getOrderId());
			TradingSyncService.getSyncResult(orderId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_071() {
		Logger.start(true, "代购神器，多供应商，多币种下单，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Integer mchId = DGSQBaseService.createIndependenceMch("USA");

			// 创建第一个供货商商品
			AgentProductBean supplierProductBean_1 = DGSQBuildProxyChainCallService
					.createSupplierProduct(mchId, "USA", "CNY", false);

			AgentProductBean agentProductBean_1 = DGSQBuildProxyChainCallService
					.importAgentProduct(mchId, supplierProductBean_1);

			agentProductBean_1 = DGSQBuildProxyChainCallService
					.createIndependenceChannel(mchId, mchId,
							agentProductBean_1.getProductId(), "HKG");

			agentProductBean_1.setGoodsOwnerId(supplierProductBean_1
					.getGoodsOwnerId());

			// 创建第二个供货商商品
			AgentProductBean supplierProductBean_2 = DGSQBuildProxyChainCallService
					.createSupplierProduct(mchId, "KOR", "CNY", false);

			AgentProductBean agentProductBean_2 = DGSQBuildProxyChainCallService
					.importAgentProduct(mchId, supplierProductBean_2);

			agentProductBean_2 = DGSQBuildProxyChainCallService
					.importAgentProduct(agentProductBean_1.getSellerId(),
							agentProductBean_2);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithTwoSuppliers(agentProductBean_1, 1,
							agentProductBean_2, 3, null, 1);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(
					supplierProductBean_1.getSellerId(), orderId);
			TradingSyncService.getSyncResult(orderId);

			SqTradingCallService.sellerAcceptOrder(
					supplierProductBean_2.getSellerId(), placeOrderResp
							.getOrderList().get(1).getOrderId());
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_073() {
		Logger.start(true, "代购神器，多供应商，外币标价，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Integer mchId = DGSQBaseService.createIndependenceMch("USA");

			// 创建第一个供货商商品
			AgentProductBean supplierProductBean_1 = DGSQBuildProxyChainCallService
					.createSupplierProduct(mchId, "USA", "USD", true);

			AgentProductBean agentProductBean_1 = DGSQBuildProxyChainCallService
					.importAgentProduct(mchId, supplierProductBean_1);

			agentProductBean_1 = DGSQBuildProxyChainCallService
					.createIndependenceChannel(mchId, mchId,
							agentProductBean_1.getProductId(), "GBR");

			agentProductBean_1.setGoodsOwnerId(supplierProductBean_1
					.getGoodsOwnerId());

			// 创建第二个供货商商品
			AgentProductBean supplierProductBean_2 = DGSQBuildProxyChainCallService
					.createSupplierProduct(mchId, "USA", "USD", true);

			AgentProductBean agentProductBean_2 = DGSQBuildProxyChainCallService
					.importAgentProduct(mchId, supplierProductBean_2);

			agentProductBean_2 = DGSQBuildProxyChainCallService
					.importAgentProduct(agentProductBean_1.getSellerId(),
							agentProductBean_2);

			String currency = supplierProductBean_1.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithTwoSuppliers(agentProductBean_1, 1,
							agentProductBean_2, 3, currency, null);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(
					supplierProductBean_1.getSellerId(), orderId);
			TradingSyncService.getSyncResult(orderId);

			SqTradingCallService.sellerAcceptOrder(
					supplierProductBean_2.getSellerId(), placeOrderResp
							.getOrderList().get(1).getOrderId());
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_074() {
		Logger.start(true, "代购神器，代理链（货头-店主），渠道商负利润订单，已接单，已结算，渠道商没有余额扣除，无法结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderNegativeProfit(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, productBean.getCurrency(),
							null, null);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_075() {
		Logger.start(true, "代购神器，代理链（货头-店主），渠道商负利润订单，渠道商有余额扣除，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderNegativeProfit(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, productBean.getCurrency(),
							null, null);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			String accountid1 = AccountCallServiceV2.getAccountId(
					(int) productBean.getSellerId(),
					ShenqiSettlementBuildVerifyService.getAccountType(0,
							productBean.getCurrency(), false));
			AccountCallServiceV2.resetAccount(accountid1,
					new BigDecimal(600000), new BigDecimal(0));

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_076() {
		Logger.start(true, "代购神器，代理链（货头-店主），外币标价，渠道商负利润订单，渠道商有余额扣除，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false,
							true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderNegativeProfit(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, productBean.getCurrency(),
							null, null);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			String accountid1 = AccountCallServiceV2.getAccountId(
					(int) productBean.getSellerId(),
					ShenqiSettlementBuildVerifyService.getAccountType(0,
							productBean.getCurrency(), false));
			AccountCallServiceV2.resetAccount(accountid1,
					new BigDecimal(600000), new BigDecimal(0));

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	// 盛付通支付订单，有商品或订单利润为负
	public void Tc_ShenqiSettlement_077() {
		Logger.start(true, "代购神器，代理链（货头-店主），盛付通支付，渠道商负利润订单，渠道商有余额扣除，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false,
							false);

			// AgentProductBean productBean = new AgentProductBean();
			//
			// productBean.setCatalogList(Arrays.asList("c6249755",
			// "c6249754"));
			// productBean.setCurrency("CNY");
			// productBean.setGoodsOwnerId(autotest_goodsOwnerId);
			// productBean.setProductId("p3443234");
			// productBean.setRootCatalogList(Arrays.asList("c6249751",
			// "c6249750"));
			// productBean.setRootProductId("p3443232");
			// productBean.setSellerId(500694307);
			// productBean.setSellerLoginId("asdaf");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderNegativeProfit(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, productBean.getCurrency(),
							null, null, 2);

			// TradingServiceResp placeOrderResp =
			// SqTradingCallService.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			String accountid1 = AccountCallServiceV2.getAccountId(
					(int) productBean.getSellerId(),
					ShenqiSettlementBuildVerifyService.getAccountType(1,
							productBean.getCurrency(), false));
			AccountCallServiceV2.resetAccount(accountid1,
					new BigDecimal(600000), new BigDecimal(0));

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_079() {
		Logger.start(true,
				"代购神器，代理链（货头-渠道商-渠道商-代理），未调价，已接单，货头为白名单用户，货头美元币种，渠道商特殊币种韩元"
						+ "渠道商负利润订单，没有足够的余额，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							false);

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"KOR");

			// 使用人民币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderNegativeProfit(productBean, BigDecimal.ZERO,
							whitelistGoodsOwnerId, "CNY", null, null);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			String accountid1 = AccountCallServiceV2.getAccountId(
					(int) productBean.getSellerId(),
					ShenqiSettlementBuildVerifyService.getAccountType(1,
							productBean.getCurrency(), false));
			AccountCallServiceV2.resetAccount(accountid1,
					new BigDecimal(600000), new BigDecimal(0));

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();
			Thread.sleep(5000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_082() {
		Logger.start(true, "代购神器外币标价商品，盛付通支付，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) dualPayModeGoodsOwnerId, 0, false,
							true);
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, null, 2, dualPayModeGoodsOwnerId,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRateForTe = DGSQBaseService
					.getCurrencyConfig(currency).getExchangeRmbRateForTe();

			// 支付网关支付回调交易
			SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(BigDecimal.ZERO)
									.multiply(exchangeRmbRateForTe)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(dualPayModeGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_083() {
		Logger.start(true,
				"代购神器外币标价商品，直销订单并支付，CustomSettlementCurrencyType为1,hipopay渠道, 未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) dualPayModeGoodsOwnerId, 0, false,
							true);
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 1, 1, dualPayModeGoodsOwnerId,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer");

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRate = DGSQBaseService.getCurrencyConfig(
					currency).getExchangeRmbRate();

			// 支付网关支付回调交易
			SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(BigDecimal.ZERO)
									.multiply(exchangeRmbRate)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), currency);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(dualPayModeGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			Thread.sleep(5000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_084() {
		Logger.start(true,
				"代购神器外币标价商品，商品标价与货头结算币种不一致, 直销订单并支付,hipopay渠道, 未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) multiCurrencyGoodsOwnerId, 0,
							false, "JPY");
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, null, 1,
							multiCurrencyGoodsOwnerId,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer");

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRate = DGSQBaseService.getCurrencyConfig(
					currency).getExchangeRmbRate();

			SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(BigDecimal.ZERO)
									.multiply(exchangeRmbRate)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), "CNY", "USD");

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(multiCurrencyGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			Thread.sleep(5000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_085() {
		Logger.start(true,
				"代购神器外币标价商品，商品标价与货头结算币种不一致, 代理订单并支付,hipopay渠道, 未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) multiCurrencyGoodsOwnerId, 0,
							false, "JPY");

			String currency = productBean.getCurrency();

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"JPN");

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"CHN");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, null, 1,
							multiCurrencyGoodsOwnerId, currency);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer");

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRate = DGSQBaseService.getCurrencyConfig(
					currency).getExchangeRmbRate();

			SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(BigDecimal.ZERO)
									.multiply(exchangeRmbRate)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), "CNY", "USD");

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(multiCurrencyGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			Thread.sleep(5000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_098() {
		Logger.start(true, "代购神器，代理链（货头-店主），渠道商负利润订单，渠道商有余额扣除，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderNegativeProfit(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, productBean.getCurrency(),
							null, null);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			String accountid1 = AccountCallServiceV2.getAccountId(
					(int) productBean.getSellerId(),
					ShenqiSettlementBuildVerifyService.getAccountType(0,
							productBean.getCurrency(), false));
			AccountCallServiceV2.resetAccount(accountid1,
					new BigDecimal(600000), new BigDecimal(0));

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 退货退款
			SqTradingCallService.orderApplyRefund(placeOrderResp, null);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isRefunded", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_101() {
		Logger.start(true, "代购神器交易下单，直销订单，带有服务费税率，无需收取手续费，未调价，已接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithServiceRate(productBean);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_109() {
		Logger.start(true, "代购神器，代理裂变（货头-店主），1个邀请人，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPromotersProxychain((int) proxyFissionGoodsOwnerId,
							1, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, proxyFissionGoodsOwnerId);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_110() {
		Logger.start(true, "代购神器，代理裂变（货头-店主），2个邀请人，未调价，已发货，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPromotersProxychain((int) proxyFissionGoodsOwnerId,
							2, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, proxyFissionGoodsOwnerId);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(proxyFissionGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 发货
			SqTradingCallService.delivery(proxyFissionGoodsOwnerId, orderId,
					1234L, null);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 代理裂变结算
			ShenqiSettlementService.executeProxyFissionSettlementTask();

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_111() {
		Logger.start(true,
				"代购神器，代理裂变（货头-店主），3个邀请人，未调价，已发货，已结算，分销裂变预期结算时间为10天以后");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPromotersProxychain((int) proxyFissionGoodsOwnerId,
							3, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, proxyFissionGoodsOwnerId);

			// 添加一个预期结算时间为10天的配置
			SaveProxyFissionConfigReq saveProxyFissionConfigReq = SaveProxyFissionConfigReq
					.buildStandardSaveProxyFissionConfigReq(
							proxyFissionGoodsOwnerId)
					.withProxyFissionSettlementDelayDays(10);
			ShenqiSettlementService
					.saveProxyFissionConfigCall(saveProxyFissionConfigReq);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(proxyFissionGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 发货
			SqTradingCallService.delivery(proxyFissionGoodsOwnerId, orderId,
					1234L, null);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 代理裂变结算
			ShenqiSettlementService.executeProxyFissionSettlementTask();

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

			// 复原配置
			saveProxyFissionConfigReq = SaveProxyFissionConfigReq
					.buildStandardSaveProxyFissionConfigReq(proxyFissionGoodsOwnerId);
			ShenqiSettlementService
					.saveProxyFissionConfigCall(saveProxyFissionConfigReq);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_112() {
		Logger.start(true,
				"代购神器，代理裂变（货头-店主），2个邀请人，带折扣，BaseCommissionType为1，外币支付，已发货，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPromotersProxychain((int) proxyFissionGoodsOwnerId,
							2, true);
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.TEN,
							proxyFissionGoodsOwnerId, currency);

			// BaseCommissionType为1
			SaveProxyFissionConfigReq saveProxyFissionConfigReq = SaveProxyFissionConfigReq
					.buildStandardSaveProxyFissionConfigReq(
							proxyFissionGoodsOwnerId).withBaseCommissionType(1);
			ShenqiSettlementService
					.saveProxyFissionConfigCall(saveProxyFissionConfigReq);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(proxyFissionGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 发货
			SqTradingCallService.delivery(proxyFissionGoodsOwnerId, orderId,
					1234L, null);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 代理裂变结算
			ShenqiSettlementService.executeProxyFissionSettlementTask();

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

			// 复原配置
			saveProxyFissionConfigReq = SaveProxyFissionConfigReq
					.buildStandardSaveProxyFissionConfigReq(
							proxyFissionGoodsOwnerId).withBaseCommissionType(2);
			ShenqiSettlementService
					.saveProxyFissionConfigCall(saveProxyFissionConfigReq);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_113() {
		Logger.start(true, "代购神器，代理裂变（货头-店主），2个邀请人，多商品，带优惠，盛付通支付，已发货，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPromotersProxychain((int) proxyFissionGoodsOwnerId,
							2, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithAllPromotion(productBean, BigDecimal.ZERO,
							proxyFissionGoodsOwnerId);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(proxyFissionGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 发货
			SqTradingCallService.delivery(proxyFissionGoodsOwnerId, orderId,
					1234L, null);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_114() {
		Logger.start(true, "代购神器，代理裂变（货头-店主），1个邀请人，销售金额不足，未调价，已发货，无法结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPromotersProxychain((int) proxyFissionGoodsOwnerId,
							1, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, proxyFissionGoodsOwnerId);

			// 添加一个CommissionLimit为10w的配置
			SaveProxyFissionConfigReq saveProxyFissionConfigReq = SaveProxyFissionConfigReq
					.buildStandardSaveProxyFissionConfigReq(
							proxyFissionGoodsOwnerId).withCommissionLimit(
							new String("100000.00"));
			ShenqiSettlementService
					.saveProxyFissionConfigCall(saveProxyFissionConfigReq);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(proxyFissionGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 发货
			SqTradingCallService.delivery(proxyFissionGoodsOwnerId, orderId,
					1234L, null);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 代理裂变结算
			ShenqiSettlementService.executeProxyFissionSettlementTask();

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

			saveProxyFissionConfigReq = SaveProxyFissionConfigReq
					.buildStandardSaveProxyFissionConfigReq(
							proxyFissionGoodsOwnerId).withCommissionLimit(
							"0.00");
			ShenqiSettlementService
					.saveProxyFissionConfigCall(saveProxyFissionConfigReq);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_115() {
		Logger.start(true, "代购神器，代理裂变，直销订单，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) proxyFissionGoodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, proxyFissionGoodsOwnerId);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);


		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_ShenqiSettlement_120() {
		Logger.start(true, "代购神器，直销商下单，yabang支付，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) yabandGoodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder1(productBean, productBean.getSellerId());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(productBean.getSellerId(),
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_ShenqiSettlement_121() {
		Logger.start(true, "代购神器，直销商下单，yabang外币支付，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) yabandGoodsOwnerId, 0, false, true);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder1(productBean, productBean.getSellerId(),
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(productBean.getSellerId(),
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_123() {
		Logger.start(true, "代购神器，直销商下单，连锁店模式，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) chainStoreGoodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeChainStoreOrder(productBean, chainStoreGoodsOwnerId,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "501476063", "6401");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6401);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_ShenqiSettlement_127() {
		Logger.start(true, "代购神器，直销商，未调价，连锁店模式，已结算, 取消订单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) chainStoreGoodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeChainStoreOrder(productBean, chainStoreGoodsOwnerId,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "501742451", "6401");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6401);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 取消订单
			SqTradingCallService.cancelOrder(orderId,
					CancelOrderTypeEnum.SELLER_CANCEL_ORDER,
					chainStoreGoodsOwnerId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_128() {
		Logger.start(true, "代购神器，代理链（货头-店主），公共云抖音订单，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 2, false,
							false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeDouYinOrder(productBean, autotest_goodsOwnerId,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_129() {
		Logger.start(true, "代购神器，直销订单，公共云直播订单，盛付通支付，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false,
							false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithUserClick(productBean,
							autotest_goodsOwnerId, false);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(true, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_130() {
		Logger.start(true, "代购神器，直销订单，部分商品为直播商品，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean1 = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false,
							false);

			AgentProductBean productBean2 = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false,
							false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithUserClickPartProduct(
							Arrays.asList(productBean1, productBean2),
							autotest_goodsOwnerId, false);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_131() {
		Logger.start(true, "代购神器，代理链（货头-店主），独立云抖音订单，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			int userId_channel = DGSQBaseService.createIndependenceMch("USA");
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain(userId_channel, 1, false,
							false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeDouYinOrder(productBean, userId_channel,
							productBean.getCurrency());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_132() {
		Logger.start(true, "代购神器，直销订单，独立云直播订单，盛付通支付，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			int userId_channel = DGSQBaseService.createIndependenceMch("USA");
			// int userId_channel = (int)autotest_goodsOwnerId;
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain(userId_channel, 0, false,
							false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithUserClick(productBean,
							(long) userId_channel, false);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(true, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			SqTradingCallService.sellerAcceptOrder(userId_channel, orderId);

			SqTradingCallService.delivery(userId_channel, orderId, null, null);

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_133() {
		Logger.start(true, "代购神器，代理链（货头-店主），使用盛付通-支付宝支付，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createShengPayProxychain((int) shengPayGoodsOwnerId, 1);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithPayChannelType(productBean,
							shengPayGoodsOwnerId, 2);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "h5sqBuyer", "6012");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6012);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_134() {
		Logger.start(true, "代购神器，直销订单，使用盛付通-支付宝支付，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createShengPayProxychain((int) shengPayGoodsOwnerId, 0);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithPayChannelType(productBean,
							shengPayGoodsOwnerId, 2);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "h5sqBuyer", "6012");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6012);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	// 特殊用例，独立商户给公共平台主商户提供商品
	public void Tc_ShenqiSettlement_135() {
		Logger.start(true, "代购神器，货头-店主-代理，独立商户代收货款，未调价，已接单，hp结算，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Integer mchId = 501861591;

			// 创建第一个供货商商品
			String productId = DGSQBaseService.createAgentProduct(501861592,
					"", false, "CNY");

			AgentProductBean supplierProductBean_1 = new AgentProductBean();

			supplierProductBean_1.setProductId(productId);
			supplierProductBean_1.setCatalogList(DGSQBaseService
					.getCatalogIdList(productId));
			supplierProductBean_1.setSellerId(501861592);
			supplierProductBean_1.setCurrency("CNY");
			supplierProductBean_1.setSellerLoginId("autotest");
			supplierProductBean_1.setGoodsOwnerId((long) 501861592);

			// 将供货商商品导入到mchId
			AgentProductBean agentProductBean_1 = DGSQBuildProxyChainCallService
					.importAgentProduct(mchId, supplierProductBean_1);

			// 将商品导入到501861593
			agentProductBean_1 = DGSQBaseService.importAgentProduct(501861593,
					"", agentProductBean_1.getProductId(), (int) mchId, true);

			agentProductBean_1.setSellerId(501861593);
			agentProductBean_1.setSellerLoginId(new DGUserWapper()
					.selectDGUserInfo(501861593).get(0).getLoginId());
			agentProductBean_1.setGoodsOwnerId(supplierProductBean_1
					.getGoodsOwnerId());

			agentProductBean_1 = DGSQBaseService.importAgentProduct(501861594,
					"", agentProductBean_1.getProductId(), (int) 501861593,
					false);

			agentProductBean_1.setSellerId(501861594);
			agentProductBean_1.setSellerLoginId(new DGUserWapper()
					.selectDGUserInfo(501861594).get(0).getLoginId());
			agentProductBean_1.setCurrency("HKD");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(agentProductBean_1,
							supplierProductBean_1.getGoodsOwnerId());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(
					supplierProductBean_1.getGoodsOwnerId(), orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 发货
			SqTradingCallService.delivery(
					supplierProductBean_1.getGoodsOwnerId(), orderId, null,
					null);
			TradingSyncService.getSyncResult(orderId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_140() {
		Logger.start(true, "代购神器，代理链（货头-店主），使用积分，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);

			Long shopId = productBean.getSellerId();

			GodPointsService.saveCreditPolicyReq(shopId);
			Thread.sleep(500);

			GodPointsService.sendCredit(shopId, 20238699L);
			Thread.sleep(500);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithIntegral(productBean, autotest_goodsOwnerId,
							20L);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(autotest_goodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			SqTradingCallService.delivery(autotest_goodsOwnerId, orderId, null,
					null);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_142() {
		Logger.start(true, "代购神器，直销订单，独立商户，使用积分，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			int userId_channel = DGSQBaseService.createIndependenceMch("USA");

			// int userId_channel = 502060981;
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain(userId_channel, 0, false,
							false);

			Long shopId = productBean.getSellerId();

			GodPointsService.saveCreditPolicyReq(shopId);
			Thread.sleep(500);

			GodPointsService.sendCredit(shopId, 20238699L);
			Thread.sleep(500);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithIntegral(productBean, userId_channel, 20L);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_143() {
		Logger.start(true,
				"代购神器，代理链（货头-渠道商-渠道商-代理），未调价，已接单，货头为白名单用户，货头美元币种，渠道商特殊币种韩元， 渠道商特殊币种为港元"
						+ "代理商欧元结算，使用积分，非外币支付，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							false);

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"KOR");

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"HKG");

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"NLD");

			Long shopId = productBean.getSellerId();

			GodPointsService.saveCreditPolicyReq(shopId);
			Thread.sleep(500);

			GodPointsService.sendCredit(shopId, 20238699L);
			Thread.sleep(500);

			// 使用人民币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithIntegralAndCurrency(productBean,
							whitelistGoodsOwnerId, 20L, "CNY");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_144() {
		Logger.start(true, "代购神器，代理裂变（货头-店主），1个邀请人，使用积分，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPromotersProxychain((int) proxyFissionGoodsOwnerId,
							1, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, (int) proxyFissionGoodsOwnerId);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_145() {
		Logger.start(true, "代购神器，代理链（货头-店主），公共云抖音订单，使用积分，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false,
							false);

			Long shopId = productBean.getSellerId();

			GodPointsService.saveCreditPolicyReq(shopId);
			Thread.sleep(500);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeDouYinOrderWithIntegral(productBean,
							autotest_goodsOwnerId, productBean.getCurrency(),
							20L);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

			// 取消订单
			SqTradingCallService.cancelOrder(orderId,
					CancelOrderTypeEnum.SELLER_CANCEL_ORDER,
					autotest_goodsOwnerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_146() {
		Logger.start(true, "代购神器，直销订单，公共云直播订单，使用积分，盛付通支付，未调价，未接单，hp结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			int userId_channel = DGSQBaseService.createIndependenceMch("USA");
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain(userId_channel, 0, false,
							false);

			GodPointsService.saveCreditPolicyReq((long) userId_channel);
			Thread.sleep(500);

			GodPointsService.sendCredit((long) userId_channel, 20238699L);
			Thread.sleep(500);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithUserClickAndIntegral(productBean,
							(long) userId_channel, 20L, false);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(true, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_151() {
		Logger.start(true, "代购神器，代理链（货头-店主），资金不归集，已接单，hp结算， 已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createFundNotCollectProxychain(
							(int) fundNotCollectGoodsOwnerId, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, fundNotCollectGoodsOwnerId);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(fundNotCollectGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_152() {
		Logger.start(true, "代购神器，代理链（货头-店主），使用盛付通支付，资金不归集，未调价，已接单，hp结算， 已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createShengPayProxychain((int) shengPayGoodsOwnerId, 1);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithPayChannelType(productBean,
							shengPayGoodsOwnerId, 2);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "6010");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, shengPayRate, 1);

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(shengPayGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_154() {
		Logger.start(true, "代购神器，代理裂变（货头-店主），内购模式，2个邀请人，未调价，已发货，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPromotersProxychain((int) proxyFissionGoodsOwnerId,
							2, false);

			Long shopId = productBean.getSellerId();

			GodPointsService.saveCreditPolicyReq(productBean.getGoodsOwnerId());
			Thread.sleep(500);

			GodPointsService.sendCredit(productBean.getGoodsOwnerId(), shopId);
			Thread.sleep(500);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithShenqiProxyBuyOrderForProxyFission(
							productBean, proxyFissionGoodsOwnerId);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(proxyFissionGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 发货
			SqTradingCallService.delivery(proxyFissionGoodsOwnerId, orderId,
					1234L, null);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 代理裂变结算
			ShenqiSettlementService.executeProxyFissionSettlementTask();

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_155() {
		Logger.start(true,
				"代购神器，代理裂变（货头-店主），内购模式，2个邀请人，带折扣，BaseCommissionType为1，已发货，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPromotersProxychain((int) proxyFissionGoodsOwnerId,
							2, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithShenqiProxyBuyOrderForProxyFission(
							productBean, proxyFissionGoodsOwnerId);

			// BaseCommissionType为1
			SaveProxyFissionConfigReq saveProxyFissionConfigReq = SaveProxyFissionConfigReq
					.buildStandardSaveProxyFissionConfigReq(
							proxyFissionGoodsOwnerId).withBaseCommissionType(1);
			ShenqiSettlementService
					.saveProxyFissionConfigCall(saveProxyFissionConfigReq);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					productBean.getCurrency());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(proxyFissionGoodsOwnerId,
					orderId);

			TradingSyncService.getSyncResult(orderId);

			// 发货
			SqTradingCallService.delivery(proxyFissionGoodsOwnerId, orderId,
					1234L, null);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 代理裂变结算
			ShenqiSettlementService.executeProxyFissionSettlementTask();

			Thread.sleep(10000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

			// 复原配置
//			saveProxyFissionConfigReq = SaveProxyFissionConfigReq
//					.buildStandardSaveProxyFissionConfigReq(
//							proxyFissionGoodsOwnerId).withBaseCommissionType(2);
//			ShenqiSettlementService
//					.saveProxyFissionConfigCall(saveProxyFissionConfigReq);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_158() {
		Logger.start(true, "代购神器，货头-店主-代理，独立商户代收货款，未调价，已接单，hp结算，已结算，供货商结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Integer mchId = 501861591;

			// 创建第一个供货商商品
			String productId = DGSQBaseService.createAgentProduct(501861592,
					"", false, "CNY");

			AgentProductBean supplierProductBean_1 = new AgentProductBean();

			supplierProductBean_1.setProductId(productId);
			supplierProductBean_1.setCatalogList(DGSQBaseService
					.getCatalogIdList(productId));
			supplierProductBean_1.setSellerId(501861592);
			supplierProductBean_1.setCurrency("CNY");
			supplierProductBean_1.setSellerLoginId("autotest");
			supplierProductBean_1.setGoodsOwnerId((long) 501861592);

			// 将供货商商品导入到mchId
			AgentProductBean agentProductBean_1 = DGSQBuildProxyChainCallService
					.importAgentProduct(mchId, supplierProductBean_1);

			// 将商品导入到501861593
			agentProductBean_1 = DGSQBaseService.importAgentProduct(501861593,
					"", agentProductBean_1.getProductId(), (int) mchId, true);

			agentProductBean_1.setSellerId(501861593);
			agentProductBean_1.setSellerLoginId(new DGUserWapper()
					.selectDGUserInfo(501861593).get(0).getLoginId());
			agentProductBean_1.setGoodsOwnerId(supplierProductBean_1
					.getGoodsOwnerId());

			agentProductBean_1 = DGSQBaseService.importAgentProduct(501861594,
					"", agentProductBean_1.getProductId(), (int) 501861593,
					false);

			agentProductBean_1.setSellerId(501861594);
			agentProductBean_1.setSellerLoginId(new DGUserWapper()
					.selectDGUserInfo(501861594).get(0).getLoginId());
			agentProductBean_1.setCurrency("HKD");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(agentProductBean_1,
							supplierProductBean_1.getGoodsOwnerId());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(
					supplierProductBean_1.getGoodsOwnerId(), orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 发货
			SqTradingCallService.delivery(
					supplierProductBean_1.getGoodsOwnerId(), orderId, null,
					null);
			TradingSyncService.getSyncResult(orderId);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isCollectingForOthersSettled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_164() {
		Logger.start(true, "代购神器，定金订单全款超时未支付，罚没定金，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false,
							false);

			TradingServiceResp placeOrderResp = SqTradingBookingOrderCallService
					.placeBookingOrder(productBean);

			OrderPo order = placeOrderResp.getOrderList().get(0).getOrderPo();
			Long userId = placeOrderResp.getUserId();
			long orderId = order.getOrderId();

			// 支付定金
			long thirdTradingId = SqTradingBookingOrderCallService
					.payBookingOrder(userId, placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), placeOrderResp
							.getPayableAmount().subtract(BigDecimal.ZERO)
							.toString(), userId.intValue(),
					BigDecimal.ZERO.toPlainString(), productBean.getCurrency());

			Thread.sleep(5000);

			// 修改paymentEndTime
			wapper.clearCache();

			OrderPo record = wapper.selectOrderbyOrderId(orderId);

			Calendar calendar = Calendar.getInstance();
			calendar.setTime(new Date());
			calendar.add(Calendar.DAY_OF_MONTH, -10);

			record.setPaymentEndTime(calendar.getTime());

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getEarnestPaymentId();

			// 修改二次确认时间
			wapper.orderMapper.updateByPrimaryKey(record);

			// 自动取消二次确认订单
			SqTradingBookingOrderCallService
					.bookingOrderUserViolationAutoCancel(orderId);
			Thread.sleep(5000);

			// 定金罚没结算
			ShenqiSettlementService.doEarnestPunishmentSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_165() {
		Logger.start(true, "代购神器，独立主商户，定金订单全款超时未支付，罚没定金，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createMultiCodeProxychain((int) 502060981L, false);

			TradingServiceResp placeOrderResp = SqTradingBookingOrderCallService
					.placeBookingOrder(productBean);

			OrderPo order = placeOrderResp.getOrderList().get(0).getOrderPo();
			Long userId = placeOrderResp.getUserId();
			long orderId = order.getOrderId();

			// 支付定金
			long thirdTradingId = SqTradingBookingOrderCallService
					.payBookingOrder(userId, placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), placeOrderResp
							.getPayableAmount().subtract(BigDecimal.ZERO)
							.toString(), userId.intValue(),
					BigDecimal.ZERO.toPlainString(), productBean.getCurrency());

			Thread.sleep(5000);

			// 修改paymentEndTime
			wapper.clearCache();

			OrderPo record = wapper.selectOrderbyOrderId(orderId);

			Calendar calendar = Calendar.getInstance();
			calendar.setTime(new Date());
			calendar.add(Calendar.DAY_OF_MONTH, -10);

			record.setPaymentEndTime(calendar.getTime());

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getEarnestPaymentId();

			// 修改二次确认时间
			wapper.orderMapper.updateByPrimaryKey(record);

			// 自动取消二次确认订单
			SqTradingBookingOrderCallService
					.bookingOrderUserViolationAutoCancel(orderId);
			Thread.sleep(5000);

			// 定金罚没结算
			ShenqiSettlementService.doEarnestPunishmentSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_166() {
		Logger.start(true, "代购神器，直销商下单，使用兑换券，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithExchangeCoupon(productBean,
							productBean.getSellerId());

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(productBean.getSellerId(),
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_167() {
		Logger.start(true, "代购神器，直销商下单，只有一个商品，使用兑换券，支付金额为0，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeFreeOrderWithExchangeCoupon(productBean,
							productBean.getSellerId());

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			SqTradingMqService.updateLiveOrder(false, orderId);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			// 接单
			SqTradingCallService.sellerAcceptOrder(productBean.getSellerId(),
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_168() {
		Logger.start(true, "中免澳门大会员，使用积分下单并支付，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) macaoCDFGoodsOwnerId, 0, false,
							true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeCDFMacaoOrderIntegral(productBean, 10L);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getMainOrderId(), "502665591", "7200");

			SqTradingCallService.orderPayCallBack(thirdTradingId, userId,
					totalPrice);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(1000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(productBean.getSellerId(),
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_ShenqiSettlement_169() {
		Logger.start(true, "中免国内订单，招行支付，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false,
							false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithCMBPayAndCrossBoderType(productBean, 2);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getMainOrderId(), "500024716", "8000");

			SqTradingCallService.orderPayCMBCallBack(thirdTradingId, userId,
					totalPrice);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(1000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(productBean.getSellerId(),
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_ShenqiSettlement_170() {
		Logger.start(true, "中免跨境订单，招行支付，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false,
							false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithCMBPayAndCrossBoderType(productBean, 1);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getMainOrderId(), "500024716", "8000");

			SqTradingCallService.orderPayCMBCallBack(thirdTradingId, userId,
					totalPrice);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(1000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(productBean.getSellerId(),
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 发货
			SqTradingCallService.delivery(autotest_goodsOwnerId, orderId, null,
					null);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_ShenqiSettlement_171() {
		Logger.start(true, "中免跨境、国内组合订单，招行支付，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false,
							false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithMixedCMBPay(productBean);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getMainOrderId(), "500024716", "8000");

			SqTradingCallService.orderPayCMBCallBack(thirdTradingId, userId,
					totalPrice);

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(1000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(productBean.getSellerId(),
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 发货
			SqTradingCallService.delivery(autotest_goodsOwnerId, orderId, null,
					null);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_172() {
		Logger.start(true, "代购神器，平台供货商，代理链（货头-店主），未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPlatformProxychain(
							(int) platformSupplierGoodsOwnerId, 1, false, "CNY");
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, platformSupplierGoodsOwnerId);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(
					platformSupplierGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_173() {
		Logger.start(
				true,
				"代购神器，代理链（平台供货商-渠道商-渠道商-渠道商-代理），未调价，已接单，第一个渠道商为白名单用户，货头美元币种，渠道商特殊币种韩元， 渠道商特殊币种为港元"
						+ "代理商欧元结算，非外币支付，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPlatformProxychain(
							(int) platformSupplierGoodsOwnerId,
							(int) whitelistGoodsOwnerId, 1, false, "CNY");

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"KOR");

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"HKG");

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"NLD");

			// 使用人民币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, platformSupplierGoodsOwnerId);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(
					platformSupplierGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_174() {
		Logger.start(true, "代购神器，平台供货商-独立商户-店主，未调价，已接单，hp结算，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPlatformIndependenceProxychain(
							(int) platformSupplierGoodsOwnerId,
							(int) platformIndependentGoodsOwnerId, 2, "CNY");

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, platformSupplierGoodsOwnerId);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			Thread.sleep(10000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(
					platformSupplierGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_175() {
		Logger.start(true, "代购神器平台供货商交易下单,多个商品，一个订单，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPlatformProxychain(
							(int) platformSupplierGoodsOwnerId, 1, false, "CNY");
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithMultiProsInOneOrder(productBean);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long userId = placeOrderResp.getUserId();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), placeOrderResp
							.getPayableAmount().subtract(BigDecimal.ZERO)
							.toString(), (int) userId,
					BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(
					(int) platformSupplierGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			Thread.sleep(5000);

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	// 需要修改whitelistGoodsOwnerId的分摊费率为95
	public void Tc_ShenqiSettlement_176() {
		Logger.start(true, "代购神器，货头为白名单用户，下级结算金额不够手续费分摊，手续费全部由货头分摊，外币支付，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 美元货头
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createWhiteMerchantProxychain((int) whitelistGoodsOwnerId,
							true);

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"USA");

			// 设置下级费率百分比
			GodmchManageCallService.setAgentRate(whitelistGoodsOwnerId, 399144,
					new BigDecimal("95"));

			productBean = DGSQBuildProxyChainCallService.createAgent(
					productBean.getSellerId(), productBean.getProductId(),
					"USA");

			// 外币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							whitelistGoodsOwnerId, "USD");

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), "USD");

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(whitelistGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);
			map.put("isForeignExchangeBid", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	// 需要修改whitelistGoodsOwnerId的分摊费率为95
	public void Tc_ShenqiSettlement_177() {
		Logger.start(
				true,
				"代购神器，代理链（平台供货商-渠道商-渠道商），货头为白名单用户，下级结算金额不够手续费分摊，手续费全部由货头分摊，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPlatformProxychain(
							(int) platformSupplierGoodsOwnerId,
							(int) whitelistGoodsOwnerId, 1, false, "CNY");

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"KOR");

			productBean = DGSQBuildProxyChainCallService.createChannel(
					productBean.getSellerId(), productBean.getProductId(),
					"HKG");

			// 使用人民币支付
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, platformSupplierGoodsOwnerId);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			// hp结算
			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(
					platformSupplierGoodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ShenqiSettlement_178() {
		Logger.start(true, "代购神器，离岸人名币结算，未调价，已接单，已结算");
		try {
			// 创建订单
			Logger.comment("前置数据准备");


			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) CHNGoodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			SqTradingMqService.updateLiveOrder(false, orderId);

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "500024716");

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			long paymentId = wapper.selectOrderbyOrderId(orderId)
					.getPaymentId();

			PaymentPo payment = wapper.selectPaymentById(paymentId);

			this.onHpSettled(paymentId, payment, null, 1);

			// 接单
			SqTradingCallService.sellerAcceptOrder(CHNGoodsOwnerId,
					orderId);
			TradingSyncService.getSyncResult(orderId);

			// 代购神器结算
			ShenqiSettlementService.doSettlement();

			// 订单期望结算map
			HashMap<String, Boolean> map = new HashMap<>();

			map.put("hpSettled", true);
			map.put("settled", true);

			this.verify(paymentId, map);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	public static void main(String[] args) throws Exception {
//
//		Ts_ShenqiSettlement test = new Ts_ShenqiSettlement();
//
//		Long paymentId = Long.valueOf("21383228699");
//
//		hpSettledReq = new OnHpSettledReq();
//
//		hpSettledReq.setTradingId(paymentId);
//		hpSettledReq.setSettleFee(null);
//
//		// 订单期望结算map
//		HashMap<String, Boolean> map = new HashMap<>();
//
//		map.put("hpSettled", true);
//		map.put("settled", true);
//
//		test.verify(paymentId, map);

		ArrayList<Long> payOrderList = new ArrayList<>();

		payOrderList.add(14329886065L);
		payOrderList.add(14329876065L);
		payOrderList.add(14329856065L);
		payOrderList.add(14329846065L);
		payOrderList.add(14329836065L);
		payOrderList.add(14329826065L);
		payOrderList.add(14329866065L);

		// //
		for (int i = 0; i < payOrderList.size(); i++) {

			Long orderId = payOrderList.get(i);

			OrderPo orderPo = wapper.selectOrderbyOrderId(orderId);

			// 如果订单不是待支付
			if (orderPo.getOrderStatus() != 1)
				continue;

			Long mainOrderId = orderPo.getMainOrderId();

			// // 支付订单
			// Long thirdTradingId =
			// SqTradingCallService.payOrder(orderPo.getUserId(),
			// mainOrderId, "502665591", "7200");
			//
			// SqTradingCallService.orderPayCallBack(thirdTradingId,
			// orderPo.getUserId(),
			// orderPo.getPayableAmount());

//			// 支付订单
//			Long thirdTradingId = SqTradingCallService.payOrder(
//					orderPo.getUserId(), orderPo.getMainOrderId());
//
//			BigDecimal payableAmount = wapper
//					.selectOrderbyMainOrderId(mainOrderId).stream()
//					.map(order -> order.getPayableAmount())
//					.reduce(BigDecimal.ZERO, BigDecimal::add);
			//
			  Long thirdTradingId = SqTradingBookingOrderCallService
			  .payBookingOrder(orderPo.getUserId(),
			  orderPo.getMainOrderId());

			  BigDecimal payableAmount = wapper
			  .selectOrderbyMainOrderId(mainOrderId).stream()
			  .map(order -> order.getPayableAmount())
			  .reduce(BigDecimal.ZERO, BigDecimal::add);
			//
			// // 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(String
					.valueOf(thirdTradingId), String.valueOf(payableAmount),
					orderPo.getUserId().intValue(), BigDecimal.ZERO
							.toPlainString());
		}

		// SqTradingCallService.sellerAcceptOrder(501861592, 13039758699L);
		//
		// SqTradingCallService.delivery(501861592, 13039758699L, 1234L, null);

		// SqTradingCallService.cancelOrder(1420109232,
		// CancelOrderTypeEnum.SELLER_CANCEL_ORDER, 501720438);

		// //
		// System.out.println(accountType);

		// Calendar from = Calendar.getInstance();
		// Calendar to = Calendar.getInstance();
		//
		// from.setTime(YMTDateUtil.getDate("2019-02-07 13:59:13",
		// YMTDateUtil.YMDHMS));
		//
		// System.out.println(YMTDateUtil.diffYear(to.getTime(),
		// from.getTime()));

		// System.out.println(new BigDecimal("103.0361").setScale(2,
		// BigDecimal.ROUND_DOWN));

		// int userId_channel = DGSQBaseService.createIndependenceMch("USA");
		// SqTradingCallService.createIndependenceProxychain(userId_channel,
		// false);

		// System.out.println(new BigDecimal("6.99056").setScale(2,
		// RoundingMode.HALF_UP));
	}
}
